<?php

class M_search extends CI_Model {

    function __construct() {
        parent::__construct();
        $this->load->database();
    }

    function count_all($search_term) {
        $this->db->like('tenhoa', $search_term);
        $this->db->from('hoa');
        return $this->db->count_all_results();
    }

    public function get_results($search_term, $number, $offset) {
        // Use the Active Record class for safer queries.
        $this->db->select('*');
        $this->db->from('hoa');
        $this->db->like('tenhoa', $search_term);
        $this->db->limit($number, $offset);
        // Execute the query.
        $query = $this->db->get();

        // Return the results.
        return $query->result_array();
    }

}
